// err define
let err = {};

// redis
err.redis = {
    internalError: {msg: 'Redis 内部错误', code: '000001'}
};

// mongodb
err.mongodb = {
    internalError: {msg: 'Mongodb 内部错误', code: '000002'}
};
// xlsx
err.xlsx = {
    readError: {msg: '读取 xlsx 异常', code: '000003'}
};
err.serverInternalError = {msg: '服务器内部错误', code: '1'};
err.urlError = {msg: '链接错误', code: '2'};


// user
err.userNotLogin = {msg: '未登录', code: '001001'};
err.userRegisterFail = {msg: '注册失败', code: '001002'};
err.userUserExist = {msg: '用户已存在', code: '001003'};
err.userVerifyCodeInvalid = {msg: '验证码不合法', code: '001004'};
err.userVerifyCodeLater = {msg: '稍后获取验证码', code: '001005'};
err.userPasswordError = {msg: '密码错误', code: '001006'};
err.userNotExist = {msg: '用户不存在', code: '001007'};
err.userIsDeleted = {msg: '用户已删除', code: '001008'};
err.userNoAuthorization = {msg: '用户无权限', code: '001009'};
err.userCellphoneEmpty = {msg: '手机号为空', code: '001010'};
err.userPasswordEmpty = {msg: '密码为空', code: '0010011'};
err.userCellphoneExist = {msg: '手机号已经存在', code: '001012'};
err.userNicknameExist = {msg: '昵称已经存在', code: '001013'};
err.userNicknameDuplicate = {msg: '昵称重复', code: '001014'};
err.userEmailExist = {msg: '邮箱已经存在', code: '001015'};
err.userEmailDuplicate = {msg: '邮箱重复', code: '001016'};
err.userDuplicate = {msg: '用户重复', code: '001017'};

// register
err.userRegisterCellphoneEmpty = {msg: '手机号为空', code: '001018'};
err.userRegisterVerifyCodeEmpty = {msg: '验证码为空', code: '001019'};
err.userRegisterPasswordEmpty = {msg: '密码为空', code: '001020'};
// login
err.userLoginCellphoneEmpty = {msg: '手机号为空', code: '001021'};
err.userLoginPasswordEmpty = {msg: '密码为空', code: '001022'};
err.userLoginSessionTimeout = {msg: '登录 session 超时', code: '001023'};
// verify
err.userVerifyCellphoneEmpty = {msg: '手机号码为空', code: '001023'};
err.userVerifyVerifyCodeOutOfDate = {msg: '验证码超时', code: '001024'};

// book
err.book = {
    notExist: {msg: '书籍不存在', code: '005009'},
    isDeleted: {msg: '书籍已删除', code: '005009'},
    titleEmpty: {msg: '书籍标题为空', code: '005009'},
    isbnEmpty: {msg: 'isbn 为空', code: '005009'},
    imageEmpty: {msg: '封面为空', code: '005009'},
    isbnExist: {msg: 'isbn 存在', code: '005009'},
    isbn10Duplicate: {msg: 'isbn10 存在', code: '005009'},
    isbn13Duplicate: {msg: 'isbn13 存在', code: '005009'},
    bookNotFound: {msg: '未找到该书籍', code: '005009'},
};


// utils
err.uploadFileEmpty = {msg: '文件为空', code: '021001'};
err.uploadIdEmpty = {msg: 'ID 为空', code: '021002'};
err.uploadKindEmpty = {msg: '类别为空', code: '021003'};
err.uploadImageBufferEmpty = {msg: '图片 Buffer 为空', code: '021004'};
err.uploadImageBucketNameEmpty = {msg: 'Bucket name 为空', code: '021005'};
err.uploadImageQiNiuFailure = {msg: '图片上传七牛失败', code: '021006'};


// resource
err.resource = {
    nameInvalid: {msg: '资源不合法', code: '027001'},
    notExist: {msg: '资源不存在', code: '027002'}
};


// check
err.check = {
    statusEmpty: {msg: '审核状态为空', code: '028001'},
    notExist: {msg: '资源不存在', code: '028002'}
};

module.exports = err;